$(function () {

    function hides() {
        $('#busuanzi_container_site_pv').hide();
        $('#busuanzi_container_page_pv').hide();
        $('#busuanzi_container_site_uv').hide();
    }

    function texts(json) {
        $('#busuanzi_value_site_pv').text(json.site_pv);
        $('#busuanzi_value_page_pv').text(json.page_pv);
        $('#busuanzi_value_site_uv').text(json.site_uv);
    }

    function shows() {
        $('#busuanzi_container_site_pv').show();
        $('#busuanzi_container_page_pv').show();
        $('#busuanzi_container_site_uv').show();
    }

    hides();

    $.ajax({
        type: 'GET',
        url: '//service.ibruce.info/busuanzi',
        headers: {accept: "application/vnd.busuanzi.v2+json"},
        timeout: 3000,
        dataType: 'jsonp',
        jsonp: 'jsonpCallback',
        success: function (data) {
            var values = eval(data);
            texts(values);
            shows();
        },
        error: function () {
            hides();
        }
    });
});